d237c9ad36815756685b1384a43bbb90e3aa2117,ambari-server/src/main/java/org/apache/ambari/server/controller/ControllerModule.java,ControllerModule,bindNotificationDispatchers,#,572
Before Change
scanner.addIncludeFilter(filter);
Set<BeanDefinition> beanDefinitions = scanner.findCandidateComponents(
"org.apache.ambari.server.notifications.dispatchers");
// no dispatchers is a problem
if (null == beanDefinitions || beanDefinitions.size() == 0) {
LOG.error("No instances of {} found to register", NotificationDispatcher.class);
return;
}
// for every discovered dispatcher, singleton-ize them and register with
// the dispatch factory
After Change
scanner.addIncludeFilter(filter);
beanDefinitions = scanner.findCandidateComponents("org.apache.ambari.server.notifications.dispatchers");
}
// no dispatchers is a problem
if (null == beanDefinitions || beanDefinitions.size() == 0) {
LOG.error("No instances of {} found to register", NotificationDispatcher.class);
return null;
}
// for every discovered dispatcher, singleton-ize them and register with
// the dispatch factory
for (BeanDefinition beanDefinition : beanDefinitions) {
String className = beanDefinition.getBeanClassName();
Class<?> clazz = ClassUtils.resolveClassName(className,
ClassUtils.getDefaultClassLoader());
try {
NotificationDispatcher dispatcher;
if (clazz.equals(SNMPDispatcher.class)) {
dispatcher = (NotificationDispatcher) clazz.getConstructor(Integer.class).newInstance(configuration.getSNMPUdpBindPort());
} else {
dispatcher = (NotificationDispatcher) clazz.newInstance();
}
dispatchFactory.register(dispatcher.getType(), dispatcher);
bind((Class<NotificationDispatcher>) clazz).toInstance(dispatcher);
LOG.info("Binding and registering notification dispatcher {}", clazz);
} catch (Exception exception) {
LOG.error("Unable to bind and register notification dispatcher {}",
clazz, exception);
}
}
return beanDefinitions;
}
/**